import { PickHandle } from "../type";

const nestedPickHandle: PickHandle = {

	ruleType: "nested",

	canCount: true,

	isNode: false,

	// [canCount=false]
	onlyEnter: (save, origin, str, index, char, length) => {
	},

	enter: (origin, hasRange) => {
		// ruleIndexStack
		const ruleInfo = origin.ruleIndexStack.infoCheck.info;
		if (ruleInfo.ruleType === "nested") {
			origin.ruleIndexStack.push(0, ruleInfo.ruleData.RegExpList.origin);
		} else {
			throw new Error("处理程序处理非处理程序数据");
		}
	},

	// [canCount=true]
	newExit: (enterBranch) => {
	},

	// [canCount=true]
	reenter: (enterBranch) => {
		// ruleIndexStack
		const ruleInfo = enterBranch.ruleIndexStack.infoCheck.info;
		if (ruleInfo.ruleType === "nested") {
			enterBranch.ruleIndexStack.push(0, ruleInfo.ruleData.RegExpList.origin);
		} else {
			throw new Error("处理程序处理非处理程序数据");
		}
	},

	exit: (origin, hasRange) => {
	},

	// [isNode=true]
	noodHnalde: (save, origin, rule, str, index, char, length) => {
		return false;
	},

};


export default nestedPickHandle;
